// import gcoord from "../../miniprogram_npm/gcoord/dist/gcoord";
var utils = require("../utils/apis");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    originList: [],
    tabList: ["待审核", "已审核"],
    selectValue: 14,
    loading: true,
    pageNum: 1,
    total: '',
    size: 10,
    selectedObj: {
      financeTime: "",
      financeAmt: "",
      belongArea: "",
      startTime: "",
      endTime: "",
    },
    startTime: '',
    endTime: '',
    serach_pro: ''
  },
  selectTab (e) {
    this.setData({
      selectValue: e.detail.title === "待审核" ? 14 : 15,
      originList: [],
      pageNum: 1,
    });
    this.setData({
      timer: Date.parse(new Date())
    })
    this.getInfos(this.data.timer);
  },
  goScreening () {
    this.setData({
      isUpdate: false
    })
    const content = JSON.stringify(this.data.selectedObj)
    wx.navigateTo({
      url: `/sub_jinfu/screening/screening?content=${content}`,
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad (options) {
    this.setData({
      timer: Date.parse(new Date())
    })
    this.getInfos(this.data.timer);
  },

  // 初始化数据
  async getInfos (timer) {
    this.setData({
      loading: true
    })
    wx.showLoading({
      title: "加载中",
    });
    // 全量的条件
    const params = {
      status: this.data.selectValue,
      xbdFlag: 0,
      current: this.data.pageNum,
      size: this.data.size,
      keyword: this.data.serach_pro || ''
    };
    const finalParams = { ...params, ...this.data.selectedObj }
    console.log(finalParams, "finalParams");
    const res = await utils.apis(
      "/api/finance/corReqAudit/auditPage",
      finalParams,
      "GET",
      true
    );
    if (this.data.timer == timer) {
      wx.hideLoading();
      console.log(res, "金服列表信息res");
      this.setData({
        originList: this.data.originList.concat(res.data.records),
        total: res.data.total,
        loading: false,
      });
    }
  },

  toDetail (e) {
    wx.navigateTo({
      url: `/sub_jinfu/list1_detail/list1_detail?id=${e.currentTarget.dataset.id}`,
    })
  },

  goOnChange (e) {
    // console.log(e, '1323213213')
    this.setData({
      serach_pro: e.detail,
    });
  },

  goSearch () {
    this.setData({
      pageNum: 1,
      originList: [],
    })
    this.setData({
      timer: Date.parse(new Date())
    })
    this.getInfos(this.data.timer);
  },

  scrollBottom () {
    if (this.data.pageNum * this.data.size < this.data.total) {
      this.setData({
        timer: Date.parse(new Date())
      })
      this.setData({
        pageNum: ++this.data.pageNum,
      });
      this.getInfos(this.data.timer);
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady () { },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow () {
    console.log(this.data.isUpdate, 'this.data.isUpdate')
    if (this.data.isUpdate) {
      this.setData({
        pageNum: 1,
        originList: [],
      })
      this.setData({
        timer: Date.parse(new Date())
      })
      this.getInfos(this.data.timer);
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide () { },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload () { },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh () { },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage () { },
});
